<script setup>
import baseModel from "@/components/baseModel/baseModel.vue";
import { computed, onMounted, reactive, ref, nextTick, watch } from "vue";

import { message } from "ant-design-vue";

const props = defineProps({
  progress: {
    type: Number,
    default: 0,
  },
});

import {} from "@ant-design/icons-vue";

const dialog = ref(null);

const emit = defineEmits(["isClose"]);

const closeModal = () => {
  dialog.value.closeModal();
};

const showModal = () => {
  dialog.value.showModal();
};

const isStopImport = () => {
  emit("isClose");
  dialog.value.closeModal();
};

defineExpose({
  showModal,
  closeModal,
});
</script>

<template>
  <div class="audition">
    <!-- 
      :title="null"

     -->
    <baseModel
      ref="dialog"
      :contentWidth="'554px'"
      minWidth="554px"
      :zIndex="9999"
      :getContainer="() => document.queryselector('.audition')"
      :closable="false"
      :maskClosable="false"
    >
      <template #title> <div></div></template>
      <template #content>
        <div class="content">
          <img src="./img/loading.gif" class="title_img" alt="" />
          <p>素材正在导入中, 请稍候...</p>
          <span>正在导入素材......</span>
          <a-progress
            :stroke-color="{
              '0%': '#108ee9',
              '100%': '#87d068',
            }"
            :percent="props.progress"
            status="active"
          />
        </div>
      </template>
      <template #footer>
        <div class="bottom">
          <a-popconfirm
            ok-text="确认"
            cancel-text="取消"
            @confirm="isStopImport"
            placement="topRight"
            :getPopupContainer="
              (triggerNode) => {
                return triggerNode.parentNode;
              }
            "
          >
            <template #title>
              <div style="width: 288px">
                <span style="color: #232425; font-weight: 600; font-size: 15px"
                  >您确定要取消吗？</span
                >
                <p
                  style="
                    color: #64666b;
                    margin: 0;
                    margin-top: 5px;
                    font-size: 13px;
                    font-weight: 400;
                  "
                >
                  取消操作将导致未成功下载的素材无法导入
                </p>
              </div>
            </template>
            <a-button class="btn" key="submit" type="primary">{{
              props.progress == 100 ? "完成" : "取消"
            }}</a-button>
          </a-popconfirm>
        </div>
      </template>
    </baseModel>
  </div>
</template>

<style lang="less" scoped>
.title_box {
  span {
    font-size: 18px;
    color: #0c0d0e;
  }
}

.content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;

  .loding {
    margin-top: 50px;
  }

  .title_img {
    width: 120px;
    height: 120px;
    object-fit: contain;
  }

  p {
    font-weight: 600;
    font-size: 16px;
  }

  span {
    color: #888;
  }
}

.bottom {
  display: flex;

  .btn {
    margin-left: auto;
  }
}
</style>
